import request from '../utils/request';

const prefix = "https://story.hhui.top";

// const prefix = "http://localhost:8080";

export function queryCount() {
  return request(prefix + "/count/cc?appKey=mweb");
}

export function queryIndex() {
  return request(prefix + '/index');
}


export function queryDetail(poetryId) {
  return request(prefix + '/detail?id=' + poetryId);
}

export function searchPoetry(payload) {
  console.log('search', payload);
  if (!payload.id) {
    payload.id = 0;
  }
  return request(prefix + '/query/content', {
    method: 'POST',
    headers: {
      //'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
      // 'Content-Type': 'application/json',
      "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
    },
    body: "content=" + payload.content + "&lastId=" + payload.id,
  });

}


export function subscribePoetryService(payload) {
  console.log(payload);
  return request(prefix + '/subscribe', {
    method: 'POST',
    headers: {
      //'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
      // 'Content-Type': 'application/json',
      "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
    },
    body: "email=" + payload.email + "&nick=" + payload.nick,
  });
}
